package com.hduong.springcloud.controller;

import com.hduong.springcloud.domain.CommonResult;
import com.hduong.springcloud.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * <h3>spring-cloud-demo-parent</h3>
 * <p></p>
 *
 * @author : hduong
 * @version : 1.0
 * @date : 2020-03-23 09:55
 **/
@RestController
@RequestMapping("/account")
public class AccountController {


    @Autowired
    private AccountService accountService;

    /**
     * 扣减余额
     * @param userId
     * @param money
     * @return
     */
    @GetMapping("/decrease")
    public CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        accountService.decrease(userId, money);
        return new  CommonResult("扣减账户余额成功！",200);
    }

}
